package project.movieMap.baseLib.beans;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.*;
import java.util.Date;
import java.util.HashSet;

@Data
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Moment {
    @JsonCreator
    public Moment(@JsonProperty("content") String content) {
        this.content = content;
        date = new Date();
    }
    //说说的Id
    private int Id;
    //说说的标题
    private String title;
    //说说的内容
    private String content;
    //说说的时间
    private Date date;
    //发说说的用户Id
    private int fromUserId;
    //获赞数目
    private int vote;
    //评论Id
    private HashSet<Integer> commentId = new HashSet<>();
    //用户上传的图片
    private HashSet<String> userPhotosURL = new HashSet<>();

    public void addVote() {
        ++vote;
    }
    public void addCommentId(int id) {
        commentId.add(id);
    }
    public void removeCommentId(int id) {
            commentId.remove(id);
    }
    public void addUserPhotoURL(String url) {
        userPhotosURL.add(url);
    }
    public void removeUserPhotoURL(String url) {
        if (userPhotosURL.contains(url)) {
            userPhotosURL.remove(url);
        }
    }
}
